fix: hot wallet allowed to init perp/spot market#2168
Conversation
WalkthroughUpdated instruction account mappings in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
sdk/src/adminClient.ts (1)
260-264: Extract admin-account resolution into one helper.This branch is now duplicated again, and
sdk/src/adminClient.tsalready has several variants of privileged account selection. Centralizing it would make future hot-wallet coverage changes much harder to miss.♻️ Refactor sketch
+ private resolveAdminAccount(): PublicKey { + if (this.useHotWalletAdmin || !this.isSubscribed) { + return this.wallet.publicKey; + } + return this.getStateAccount().admin; + } ... - admin: this.useHotWalletAdmin - ? this.wallet.publicKey - : this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, + admin: this.resolveAdminAccount(),Also applies to: 679-683
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sdk/src/adminClient.ts` around lines 260 - 264, Extract the repeated ternary that decides the admin account into a single helper method on the class (e.g., resolveAdminAccount or getAdminAccount) that uses this.useHotWalletAdmin, this.wallet.publicKey, this.isSubscribed and this.getStateAccount().admin to return the correct PublicKey; replace the inline expression (the nested ternary currently producing admin: ...) and the duplicate at the other site with calls to that helper; ensure the helper is used wherever privileged account selection occurs so future hot-wallet logic changes are made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@sdk/src/adminClient.ts`:
- Around line 260-264: Extract the repeated ternary that decides the admin
account into a single helper method on the class (e.g., resolveAdminAccount or
getAdminAccount) that uses this.useHotWalletAdmin, this.wallet.publicKey,
this.isSubscribed and this.getStateAccount().admin to return the correct
PublicKey; replace the inline expression (the nested ternary currently producing
admin: ...) and the duplicate at the other site with calls to that helper;
ensure the helper is used wherever privileged account selection occurs so future
hot-wallet logic changes are made in one place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a1ec3d14-2cac-4bff-97f2-8de86fa9a8df
📒 Files selected for processing (1)
sdk/src/adminClient.ts
Summary by CodeRabbit
Release Notes